﻿@using MvcPaging
@model IPagedList<QuanLyCayXanh.Models.Tree>

@{
    ViewBag.Title = "Index";
}

<h2>Danh sách cây xanh</h2>

<table class="my-table pure-table pure-table-bordered">
    <thead>
        <tr>
            <th>STT</th>

            <th>
                @Html.DisplayNameFor(model => model.First().NameVietNam)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.First().ScientificName)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.First().PointX)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.First().PointY)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.First().FamilyTree.Name)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.First().GroupOfTree.Name)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.First().Street.Name)
            </th>       
            <th>
                @Html.DisplayNameFor(model => model.First().Ward.Name)
            </th>     
            <th></th>
        </tr>
    </thead>
    
    @{
        int count = 0;

    }
    @foreach (var item in Model)
{
    count = count + 1;
    string trClass = count % 2 == 1 ? "" : "pure-table-odd";
    <tr class="@trClass">
        <td>@count</td>
        <td>
            @Html.DisplayFor(modelItem => item.NameVietNam)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.ScientificName)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.PointX)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.PointY)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.FamilyTree.Name)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.GroupOfTree.Name)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Street.Name)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Ward.Name)
        </td>
        <td>
            <a class="pure-button" href="@Url.Action("Edit", new { id = item.Id })">
                <i class="fa fa-edit"></i>
            </a>            
            <a class="pure-button delete-link" name="@item.NameVietNam" href="@Url.Action("Delete", new { id = item.Id })">
                <i class="fa fa-remove"></i>
            </a>
        </td>
    </tr>
}

</table>
@Html.Partial("~/Views/Shared/_ActionForm.cshtml")

<div class="" id="myPager">
    @*Khong su dung ajax*@

    @Html.Raw(Html.Pager(
                new Options
                {
                    PageSize = Model.PageSize,
                    TotalItemCount = Model.TotalItemCount,
                    CurrentPage = Model.PageNumber,
                    ItemTexts = new ItemTexts() {First = "<<", Next = ">",Last=">>", Previous = "<", Page = "P" },
                    ItemIcon = new ItemIcon() { First = "icon-backward", Previous = "icon-chevron-left", Next = "icon-chevron-right", Last = "icon-forward" },
                    TooltipTitles = new TooltipTitles() { Next = "Next page", Previous = "Previous page", Page = "Page {0}." },
                    Size = Size.normal,
                    Alignment = Alignment.centered,
                    IsShowControls = true,
                    IsShowFirstLast = true,
                    CssClass = "pure-paginator"
                },
                new { controller = "Tree", action = "Index" }))
    <div class="well">
        Hiển thị <span class="badge badge-success">@Model.ItemStart</span> đến <span class="badge badge-success">@Model.ItemEnd</span>
        của <span class="badge badge-info">@Model.TotalItemCount</span> dòng
    </div>
</div>

<script type="text/javascript">
    $(".pure-paginator li").addClass("pure-button");
    $(".pure-paginator .active").addClass("pure-button-active");
</script>
